package com.xianxian.user.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xianxian.user.entity.Department;
import com.xianxian.user.entity.Role;
import com.xianxian.user.mapper.DepartmentMapper;
import com.xianxian.user.mapper.RoleMapper;
import com.xianxian.user.model.dto.DepartmentTreeDTO;
import com.xianxian.user.util.TreeUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述：
 *
 * @author zhang
 */
@Service
public class DepartmentService extends ServiceImpl<DepartmentMapper, Department> {

    public List<DepartmentTreeDTO> getTree() {
        // 获取部门数据
        List<Department> departmentList = baseMapper.selectList(null);
        if(null == departmentList || departmentList.size() == 0){
            // 没有数据，返回空树
            return null;
        }
        return TreeUtil.getDeptTree(departmentList);

    }
}
